package com.gk.chat.controller;

import com.gk.chat.common.R;
import com.gk.chat.dto.FriendDTO;
import com.gk.chat.service.ContactService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/api/v1/contact")
public class ContactController {
    @Autowired
    private ContactService contactService;

    /**
     * 获取好友列表
     * @return
     */
    @GetMapping("/list")
    public ResponseEntity<R<Map<String,List<FriendDTO>>>> list() {
        Map<String,List<FriendDTO>> map = new HashMap<>();
        map.put("items",contactService.getContactList());
        System.out.println(map);
        return ResponseEntity.ok(R.success(map));
    }

    /**
     * 搜索用户信息服务接口
     * @return
     */
    @GetMapping("/group/list")
    public ResponseEntity<R<Map<String,List<FriendDTO>>>> ServeContactGroupList(){
        Map<String,List<FriendDTO>> map = new HashMap<>();
        map.put("items",contactService.ServeContactGroupList());
        return ResponseEntity.ok(R.success(map));
    }
}
